package pathfinding
{
	import flash.geom.Vector3D;

	public class sasiedzi
	{
		public var name:String;
	
		public var punkty:Vector.<Vector3D>;
		private var maxx:Number=-99999;
		private var minx:Number=99999;
		
		private var maxy:Number=-99999;
		private var miny:Number=999999;
		
		private var maxz:Number=-999999;
		private var minz:Number=999999;
		
		
		public function sasiedzi(name:String,a:Vector3D)
		{
		   this.name=name;
		 
		   punkty=new Vector.<Vector3D>();
		   punkty.push(a);
		}
		
		public function tworzportal():Portal
		{
			for(var x:int=0;x<punkty.length;x++)
			{
				if(punkty[x].x<minx) minx=punkty[x].x;
				if(punkty[x].x>maxx) maxx=punkty[x].x;
				
				if(punkty[x].y<miny) miny=punkty[x].y;
				if(punkty[x].y>maxy) maxy=punkty[x].y;
				
				if(punkty[x].z<minz) minz=punkty[x].z;
				if(punkty[x].z>maxz) maxz=punkty[x].z;
			}
			var tempX:Number=(minx+maxx)/2;
			var tempY:Number=(miny+maxy)/2;
			var tempZ:Number=(minz+maxz)/2;
			return new Portal(-1,new Vector3D(tempX,tempY,tempZ));
			
		}
	}
}